﻿
using System;
using System.Globalization;
using System.Windows.Data;
using ZDK.Infra.Constants;

namespace ZDK.Infra.Converters
{
    #region AFN=01 复位命令
    public class Afn01F1ResetCvt : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var f1 = (Afn01_F1ResetEnum)value;
            return f1 == (Afn01_F1ResetEnum)int.Parse(parameter.ToString());
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool ck = (bool)value;
            if (!ck)
                return null;
            return (Afn01_F1ResetEnum)int.Parse(parameter.ToString());
        }
    }
    public class Afn01F3ResetModularCvt : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var f1 = (Afn01_F3ResetModularEnum)value;
            return f1 == (Afn01_F3ResetModularEnum)int.Parse(parameter.ToString());
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool ck = (bool)value;
            if (!ck)
                return null;
            return (Afn01_F3ResetModularEnum)int.Parse(parameter.ToString());
        }
    }
    #endregion

    #region AFN=04/0A 设置/查询参数
    public class Afn04F76DoorCvt : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var f1 = (Afn04_F76DoorEnum)value;
            return f1 == (Afn04_F76DoorEnum)int.Parse(parameter.ToString());
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool ck = (bool)value;
            if (!ck)
                return null;
            return (Afn04_F76DoorEnum)int.Parse(parameter.ToString());
        }
    }
    #endregion

    #region AFN=05 控制命令
    public class Afn05F74InlineNoCvt : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var f1 = (Afn05_F74InlineNoEnum)value;
            return f1 == (Afn05_F74InlineNoEnum)int.Parse(parameter.ToString());
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool ck = (bool)value;
            if (!ck)
                return null;
            return (Afn05_F74InlineNoEnum)int.Parse(parameter.ToString());
        }
    }
    public class Afn05F74OnOffCvt : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var f1 = (Afn05_F74OnOffEnum)value;
            return f1 == (Afn05_F74OnOffEnum)int.Parse(parameter.ToString());
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool ck = (bool)value;
            if (!ck)
                return null;
            return (Afn05_F74OnOffEnum)int.Parse(parameter.ToString());
        }
    }
    public class Afn05F75CabinNoCvt : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var f1 = (Afn05_F75CabinNoEnum)value;
            return f1 == (Afn05_F75CabinNoEnum)int.Parse(parameter.ToString());
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool ck = (bool)value;
            if (!ck)
                return null;
            return (Afn05_F75CabinNoEnum)int.Parse(parameter.ToString());
        }
    }
    public class Afn05F75BranchCvt : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var f1 = (Afn05_F75BranchEnum)value;
            return f1 == (Afn05_F75BranchEnum)int.Parse(parameter.ToString());
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool ck = (bool)value;
            if (!ck)
                return null;
            return (Afn05_F75BranchEnum)int.Parse(parameter.ToString());
        }
    }
    #endregion

    #region AFN=0C 实时数据
    public class Afn0CF73BoxCvt : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var f1 = (Afn0C_F73BoxEnum)value;
            return f1 == (Afn0C_F73BoxEnum)int.Parse(parameter.ToString());
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool ck = (bool)value;
            if (!ck)
                return null;
            return (Afn0C_F73BoxEnum)int.Parse(parameter.ToString());
        }
    }
    #endregion

    #region 升级
    public class UpgradeTransModelCvt : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var m = (UpgradeTransModelEnum)value;
            return m == (UpgradeTransModelEnum)int.Parse(parameter.ToString());
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool ck = (bool)value;
            if (!ck)
                return null;
            return (UpgradeTransModelEnum)int.Parse(parameter.ToString());
        }
    }
    #endregion
}
